<!DOCTYPE html>
<!--[if lt IE 7]>      <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" ng-app="myApp" class="no-js"> <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>中华爱情网</title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
  <link rel="shortcut icon" href="favicon.ico" />

  <link rel="stylesheet" href="/bower_components/all.css">


</head>
<body >
<div ng-controller="appCtrl" flex-container="row" style="position:relative;">
    <div class="toolbar bgc-blue-grey-800 tc-white-1">
        <span class="toolbar__label fs-title" ng-bind="coupon.subject"></span>
    </div>
    <div flex-item="12" class="tc-white-2  bgc-grey-300"  >

        <div flex-container="row" flex-gutter="24" style="color:black" id="content">
            <div flex-item>
                <div class="card">
                    <div class="card__img card__img--top">
                        <img ng-src="{{coupon.img_dir}}">
                    </div>
                    <div class="p+">
                        <div class="fs-title mb++" ng-bind="coupon.subject" ></div>
                        <div class="paragraph fs-body-1" style="color:black;">
                            <p>店铺名称：<span ng-bind="coupon.seller_name"></span></p>
                            <p>联系电话：<span ng-bind="coupon.tel"></span></P>
                            <p>店铺地址：<span ng-bind="coupon.address"></span></P>
                            <p>活动时间：<span ng-bind="coupon.start_time"></span>至<span ng-bind="coupon.end_time"></span></p>
                        </div>
                    </div>
                    <div class="card__actions" style="overflow-y:scroll">
                        <p id="content"></p>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <!--
    <img type="button" style="position:fixed;right:10px;bottom:10px;z-index:9999" class="right" ng-click="go_top()"src="/css/go_top.png">
    -->
</div>

<script src="/bower_components/all.js"></script>

<script src="/bower_components/jweixin.js"></script>
<!-- <script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/bower_components/angular/angular.min.js"></script> -->
<!-- <script src="/bower_components/loading-bar.js"></script> -->

<!-- <script src="/bower_components/velocity/velocity.min.js"></script> -->
<!-- <script src="/bower_components/moment/min/moment-with-locales.min.js"></script> -->
<!-- <script src="/bower_components/angular-route/angular-route.js"></script> -->
<!-- <script src="/bower_components/ng-infinite-scroll.min.js"></script> -->
<!-- <script src="/bower_components/angular-resource/angular-resource.min.js"></script> -->
<!-- <script src="/bower_components/angular-animate.min.js"></script> -->

<script type="text/javascript">
    wx.config({
        debug: false,
        appId: '<?php echo $signPackage["appId"];?>',
        timestamp: '<?php echo $signPackage["timestamp"];?>',
        nonceStr: '<?php echo $signPackage["nonceStr"];?>',
        signature: '<?php echo $signPackage["signature"];?>',
        jsApiList: [
           // 'checkJsApi',
            'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'onMenuShareQQ'
           // 'onMenuShareWeibo',
           // 'onMenuShareQZone'// 所有要调用的 API 都要加到这个列表中
        ]
    });

    var myApp = angular.module('myApp',['chieffancypants.loadingBar']);
    myApp.controller('appCtrl',['$scope','$http',function($scope,$http) { 
        var userid = "<?=$userid?>";
        var cardid = "<?=$id?>";
        $scope.go_top=function(){
          $('html,body').animate({scrollTop:0},300);
        };
        var coupon_id = {'couponId':cardid};

        $http.post('/consumer/'+userid+'/coupon',coupon_id).success(function(data){
            if (!data.error) { 
                alert("恭喜您，获取成功！")
                $http.get('/consumer/'+userid+'/coupon/'+cardid).success(function(data,status){
                    if (!data.error) {
                        $scope.coupon = data.result[0];
                        $("#content").after(data.result[0].content);
                        //分享
                        wx.ready(function () {
                            shareData = {
                                title:$scope.coupon.subject,
                                desc:$scope.coupon.seller_name,
                                link:"http://www.chinalove99.net:82/coupon/"+cardid+"/get",
                                imgUrl:"http://www.chinalove99.net:82"+$scope.coupon.img_dir
                            };
                          
                            wx.onMenuShareAppMessage(shareData);
                            wx.onMenuShareTimeline(shareData);
                            wx.onMenuShareQQ({
                                trigger: function (res) {
                                    alert("暂不支持分享到手机QQ");
                                    return false;
                                }
                            });
                        });
                    };
                });                
            }else{
                $("#content").html('<p style="padding:20px;text-align:center;color:#333;font-size:24px;">'+data.message+'</p>');
                alert(data.message);
            };
        }); 
        

    }]); 
</script>

</body>
</html>



